<template>
<div style="display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;">
<h1>购买产品【{{order.subject}}】成功，页面即将自动关闭</h1>
</div>
</template>

<script>
export default {
  name: "Success",
  data(){
    return{
      order:{},
      countdown:5,
    }
  },
  methods:{
    loadOrder(){
      let orderNo = new URLSearchParams(location.search).get("id");
      let url = "http://localhost:8080/alipay/selectById?orderNo="+orderNo;
      console.log(orderNo);
      this.axios
          .create({
            'headers': {
              'Authorization': localStorage.getItem('localJwt')
            }
          })
          .get(url).then((response) => {
        if (response.data.code == 1) {
          this.order = response.data.data;
        }
      })
    }
  },
  mounted() {
    this.loadOrder();
    this.interval = setInterval(() => {
      this.countdown -= 1;
      if (this.countdown === 0) {
        window.close();
      }
    }, 1000);
  },
  beforeUnmounted() {
    clearInterval(this.interval);
  }
}
</script>

<style scoped>

</style>